import  java.util.Scanner;
class Animals{
    public String name;
    public int age;
    public  String color;

    public void eat(){
        System.out.println(name + "正在吃饭----Animals");
    }

    public Animals(String name) {
        this.name = name;
    }
}

class Dog extends Animals{//继承只继承成员变量和成员方法，不包括静态


    public void wangWang(){
        System.out.println(name + "汪汪叫");

    }

    //方法的重写
    public void eat(){
        System.out.println(name + "正在吃狗粮");
    }



    public Dog(String name, int age) {//子类构造方法时，需要先调用父类构造方法，然后执行子类构造方法
        super(name);
        this.age=age;
    }
}



class Cat extends Animals{
    public void wangWang(){
        System.out.println(name + "喵喵叫");
    }

    public Cat(String name) {
        super(name);
    }
}

public class work {
    public static void main(String[] args) {

        //父类引用 引用了子类对象 就叫做--向上转型
        Animals animals =new Dog("阿黄",18);
        //动态绑定
        animals.eat();


        Animals animals1 = new Animals("小黑");
        animals1.eat();



//        Dog dog = new Dog("阿黄",18);
//        System.out.println(dog.name + dog.age);

    }

}


